__author__ = 'czq'
def get_client_ip(request):
  if request.META.has_key('HTTP_X_FORWARDED_FOR'):
    ip =  request.META['HTTP_X_FORWARDED_FOR']
  else:
    ip = request.META['REMOTE_ADDR']
  if ip.find(u',')!=-1:
      ip=ip.split(u',')[0]
      #return '1'
  return ip